﻿Chenxin.UI.PgContractQuickSrh = Chenxin.extend(Chenxin.UI.PageCommon, {
    actionUrl: "/service/logic/ContractQuickSearch.ashx",
    createSearch: function() {
        return new Chenxin.UI.SrhContractQuickSrh({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.MultiRowGrid({
            actionUrl: this.actionUrl + '?op=search',
            pageSize: 10,
            renderTo: 'divContracts',
            hasCheckBox: false,
            id: 'ContractsInfo',
            title: '成交快报列表',
            scope: this,
            columns: {
                ContractCode: {
                    width: 120,
                    head: '成交编号',
                    sortable: true
                },
                ContractDate: {
                    width: 80,
                    head: '成交时间',
                    sortable: true
                },
                HouseAddress: {
                    width: 314,
                    head: '房源地址',
                    sortable: true
                },
                Area: {
                    width: 100,
                    head: '面积',
                    sortable: true
                },
                BargainPrice: {
                    width: 80,
                    head: '合同标的',
                    sortable: true
                },
                Commision: {
                    width: 100,
                    items: {
                        VCommision: {
                            width: 100,
                            head: '上家佣金',
                            sortable: true
                        },
                        BCommision: {
                            width: 100,
                            head: '下家佣金',
                            sortable: true
                        }
                    }
                },
                Depart: {
                    width: 180,
                    items: {
                        VenderDepartName: {
                            width: 180,
                            head: '上家门店',
                            sortable: true
                        },
                        BuyerDepartName: {
                            width: 180,
                            head: '下家门店',
                            sortable: true
                        }
                    }
                },
                Employee: {
                    width: 120,
                    items: {
                        VenderUserName: {
                            width: 120,
                            head: '上家业务员',
                            sortable: true
                        },
                        BuyerUserName: {
                            width: 120,
                            head: '下家业务员',
                            sortable: true
                        }
                    }
                },
                Point: {
                    width: 100,
                    items: {
                        VPoint: {
                            width: 100,
                            head: '上家点数',
                            sortable: true
                        },
                        BPoint: {
                            width: 100,
                            head: '下家点数',
                            sortable: true
                        }
                    }
                },
                CommisionGeted: {
                    width: 200,
                    items: {
                        VCommisionGeted: {
                            width: 200,
                            head: '上家实收',
                            sortable: true
                        },
                        BCommisionGeted: {
                            width: 200,
                            head: '下家实收',
                            sortable: true
                        }
                    }
                },
                ArchivementDate: {
                    width: 80,
                    head: '业绩归属',
                    sortable: true,
                    renderer: function(val, field, row) {
                        if (val.indexOf('.') >= 0) {
                            return val.substring(0, 4) + '年' + val.substring(5.1) + '月';
                        }
                        else {
                            return '';
                        }
                    }
                },
                HouseCode: {
                    width: 170,
                    head: '房源编号',
                    sortable: true
                },
                BusinessType: {
                    width: 80,
                    head: '成交类型',
                    sortable: true
                },
                BargainCompanyName: {
                    width: 90,
                    head: '合同归属公司',
                    sortable: true
                }
            }
        });
    }
});

/*
*检索面板
*/
Chenxin.UI.SrhContractQuickSrh = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'divContractQuick',
    initEvent: function() {
        var objSrh = this;
        /**********事件：检索********/
        $("#btSearch").click(function() {
            if ($("#txtAreaS").val() != "" && $("#txtAreaS").val() != $("#txtAreaS").attr("defVal") && !$("#txtAreaS").val().isNum()) {
                alert("请输入数值！");
                $("#txtAreaS").focus();
                return false;
            }
            if ($("#txtAreaE").val() != "" && $("#txtAreaE").val() != $("#txtAreaE").attr("defVal") && !$("#txtAreaE").val().isNum()) {
                alert("请输入数值！");
                $("#txtAreaE").focus();
                return false;
            }
            if ($("#txtBargainPriceS").val() != "" && $("#txtBargainPriceS").val() != $("#txtBargainPriceS").attr("defVal") && !$("#txtBargainPriceS").val().isNum()) {
                alert("请输入金额！");
                $("#txtBargainPriceS").focus();
                return false;
            }
            if ($("#txtBargainPriceE").val() != "" && $("#txtBargainPriceE").val() != $("#txtBargainPriceE").attr("defVal") && !$("#txtBargainPriceE").val().isNum()) {
                alert("请输入金额！");
                $("#txtBargainPriceE").focus();
                return false;
            }
            objSrh.scope.reloadGrid();
        });

        /********事件：业务归属******/
        $("#txtArchivementDate").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });

        /********事件：开始时间******/
        $("#txtStartTime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });

        /********事件：结束时间******/
        $("#txtEndTime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM-dd',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });

        $('#txtKeyword').defText({
            deftxt: '成交编号/房源地址'
        });

        $("#txtBargainPriceS").defText({
            deftxt: '单位(万元)'
        });

        $("#txtBargainPriceE").defText({
            deftxt: '单位(万元)'
        });

        $("#txtArchivementDate").defText({
            deftxt: '年月'
        });

        $("#txtStartTime").defText({
            deftxt: '开始时间'
        });

        $("#txtEndTime").defText({
            deftxt: '结束时间'
        });

        $("#txtAreaS").defText({
            deftxt: '检索下限'
        });

        $("#txtAreaE").defText({
            deftxt: '检索上限'
        });
    },
    createComboList: function() {
        //成交类型
        var cmbBusinessType = new Chenxin.UI.Combo({
            containerId: '#BusinessType',
            tbxWidth: 45,
            items: comboCommon.BusinessType
        });

        var combl = new Chenxin.UI.StructComboList();
        var structs = combl.comboList;
        structs.push(cmbBusinessType);

        return structs;
    }
});

getcity = true; //设置需要获取城市下拉框数据

$(function() {
    var objPg = new Chenxin.UI.PgContractQuickSrh();
});